package com.tim.app.ui.adapter.personal;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.application.library.util.TimeUtil;
import com.application.library.widget.recycle.BaseRecyclerAdapter;
import com.application.library.widget.roundimg.RoundedImageView;
import com.netease.nim.uikit.common.ui.recyclerview.holder.BaseViewHolder;
import com.tim.app.R;
import com.tim.app.server.entry.InvatePersonBean;
import com.tim.app.server.result.InvateRecoderBean;
import com.tim.app.ui.adapter.search.SearchUserAdapter;
import com.tim.app.util.BitmapLoader;

import java.util.List;

/**
 * Created by wdy on 2017/8/21.
 */

public class MyInvatePersonAdapter extends BaseRecyclerAdapter<MyInvatePersonAdapter.ViewHolder, InvateRecoderBean.ResBean.ArraylistBean.ResultBean> {
    private Context context;

    public MyInvatePersonAdapter(Context context, List<InvateRecoderBean.ResBean.ArraylistBean.ResultBean> mDataList) {
        super(mDataList);
        this.context = context;
    }

    @Override
    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        ViewHolder holder = new ViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_invate_person, parent, false));
        return holder;
    }

    @Override
    public void onBindViewHolder(ViewHolder holder, int position, InvateRecoderBean.ResBean.ArraylistBean.ResultBean data) {
        holder.tv_user_name.setText(data.getUserName());
        holder.tv_regiset_time.setText("注册时间" + TimeUtil.dateToStamp(data.getCreateTime() + ""));
        holder.tv_comunt_money.setText("+" + data.getInviteUserMoney() + "元");
        holder.tv_comunt_moli.setText("+" + (int)data.getInviteUserFlower() + "朵");
        BitmapLoader.ins().loadImage(data.getUserImage(), holder.iv_head);
    }

    public static class ViewHolder extends BaseRecyclerAdapter.BaseRecyclerViewHolder {
        RoundedImageView iv_head;
        TextView tv_user_name, tv_regiset_time, tv_comunt_money, tv_comunt_moli;

        public ViewHolder(View view) {
            super(view);
            iv_head = (RoundedImageView) view.findViewById(R.id.iv_head);
            tv_user_name = (TextView) view.findViewById(R.id.tv_user_name);
            tv_regiset_time = (TextView) view.findViewById(R.id.tv_regiset_time);
            tv_comunt_money = (TextView) view.findViewById(R.id.tv_comunt_money);
            tv_comunt_moli = (TextView) view.findViewById(R.id.tv_comunt_moli);
        }
    }
}
